{% extends "base.html" %}
{% block title %}
    用户管理
{% endblock %}
{% block main %}
    <div class="col-12">
        <div class="card">
            <div class="card-header">
                <h3 class="card-title">用户列表</h3>
            </div>
            <div class="card-tools ml-3 mt-2">
                <a href="/user_add" class="btn btn-primary" style="color: white">创建用户</a>
            </div>
            <!-- /.card-header -->
            <div class="card-body">
                <table id="example1" class="table table-bordered table-striped">
                    <thead>
                    <tr>
                        <th>账号名称</th>
                        <th>真实姓名</th>
                        <th>性别</th>
                        <th>Email</th>
                        <th>联系方式</th>
                        <th class="text-center">账号状态</th>
                        <th>创建者</th>

                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {% for user in users %}
                        <tr>
                            <td>{{ user.username }}</td>
                            <td>{{ user.real_name }}</td>
                            <td>{{ user.sex }}</td>
                            <td>{{ user.email }}</td>
                            <td>{{ user.phone }}</td>
                            <td class="text-center">
                                {% if user.status == 0 %}
                                    <span class="badge badge-success">正常</span>
                                {% endif %}
                                {% if user.status == 1 %}
                                    <span class="badge badge-danger">禁用</span>
                                {% endif %} 
                            </td>
                            <td>{{ user.create_by }}</td>

                            <td>
                               <a href="/user_find_by_id?id={{ user.id }}" class="btn btn-success">修改</a>
                               <button onclick="deleteById({{ user.id }})" class="btn btn-danger">删除</button>
                            </td>
                        </tr>
                    {% endfor %}
                    </tbody>
                </table>
            </div>
            <!-- /.card-body -->
        </div>
        <!-- /.card -->
    </div>
    <!-- /.modal -->
{% endblock %}
{% block script %}
    <script src="/static/dist/js/user-list.js"></script>
{% endblock %}
